package b3.widget.basic
{
	import com.greensock.TweenLite;
	
	import flash.filters.BitmapFilterQuality;
	import flash.filters.GlowFilter;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	
	public class PopMessage extends BasicWidget
	{
		public function PopMessage(msg:String, color:uint = 0x00AA00, glowColor:uint = 0xFFFFFF, textSize:int = 24)
		{
			super();
			
			this.anchor = BasicWidget.ANCHOR_MIDDLE_MIDDLE;

			//具体信息
			var tipText:TextField = new TextField();
			tipText.selectable = false;
        	tipText.autoSize = TextFieldAutoSize.LEFT;
        	//tipText.width = textWidth;
			
        	var textFormat:TextFormat;
        	textFormat = new TextFormat("微软雅黑", textSize, color, true);
        	tipText.filters = [new GlowFilter(glowColor, 1, 1.3, 1.3, 100, BitmapFilterQuality.HIGH)];
			tipText.defaultTextFormat = textFormat;
			tipText.text = msg;
			addChild(tipText);
			this.x = -this.width / 2;
			this.y = -this.height / 2;
			TweenLite.delayedCall(1.2, disappear);
		}
		
		//消失
		public function disappear():void
		{
			TweenLite.to(this, 1, {x:this.x, y:this.y - 30, alpha:0, onComplete:close});
		}
	}
}